<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function getNumberOfBottles(total, exchange) {
        let num = 0
        // 兑换1次total会减掉exchange瓶，同时这exchange瓶还可以换一瓶
        // 相当于兑换一次消耗了exchange-1瓶
        while (total >= exchange - 1) {
          total = total - (exchange - 1)
          num += 1
        }
        return num
      }
      const res = getNumberOfBottles(10, 3)
      console.log(res)
    </script>
  </body>
</html>
